/*
 *  Document   : rec_register.js
 *  Author     : liufei
 *  Description: 
 */



/**
 * 
 */
var RecSignUp = function() {
    // Init Lock Form Validation, for more examples you can check out https://github.com/jzaefferer/jquery-validation
    var initValidata = function(){
        jQuery('.sginup-form').validate({
            errorClass: 'help-block text-right animated fadeInDown',
            errorElement: 'div',
            errorPlacement: function(error, e) {
                jQuery(e).parents('.form-group > div').append(error);
            },
            highlight: function(e) {
                jQuery(e).closest('.form-group').removeClass('has-error').addClass('has-error');
                jQuery(e).closest('.help-block').remove();
            },
            success: function(e) {
                jQuery(e).closest('.form-group').removeClass('has-error');
                jQuery(e).closest('.help-block').remove();
            },
            rules: {
                'name': {
                    required: true,
                    minlength: 3
                },
                'email': {
                    required: true,
                    email: true
                },
                'email-code': {
                    required: true,
                    minlength: 6
                },
                'password': {
                    required: true,
                    minlength: 5
                },
                'confirm-password': {
                    required: true,
                    equalTo: '#password'
                },
                'frontend-signup-terms': {
                    required: true
                }
            },
            messages: {
                'name': {
                    required: '请输入用户名',
                    minlength: '用户名长度至少3位'
                },
                'email': '请输入邮箱',
                'email-code': {
                    required: '请输入验证码',
                    minlength: '验证码长度6位'
                },

                'password': {
                    required: '请输入密码',
                    minlength: '密码长度至少5位'
                },
                'val-confirm-password': {
                    required: '请输入密码',
                    minlength: '密码长度至少5位',
                    equalTo: '两次输入的密码不一致'
                },
                'frontend-signup-terms': '你必须同意服务协议!'
            }
        });
    };

    return {
        init: function () {
            // Init Reminder Form Validation
        	initValidata();
        }
    };
}();

// Initialize when page loads
jQuery(function(){ RecSignUp.init(); });


